home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libmailtools-perl / demos / forwd_demo next >
Encoding:
Text File  |  2008-11-04  |  797 b   |  46 lines

  1. #!/usr/bin/perl -w
  2. use Mail::Internet;
  3.  
  4. @mail = <>;
  5.  
  6. $mail = Mail::Internet->new(\@mail);
  7.  
  8. $mail->remove_sig;
  9. $mail->tidy_body;
  10.  
  11. @reply = ();
  12. if(open(HDR,"$ENV{HOME}/.mailhdr")) {
  13.  @reply = <HDR>;
  14.  close(HDR);
  15. }
  16.  
  17. $rply = Mail::Internet->new(\@reply);
  18.  
  19. $subject = $mail->get('Subject');
  20.  
  21. $rply->replace('To', "");
  22. $rply->replace('Cc', "");
  23. $rply->replace('Subject',$subject);
  24.  
  25. $rply->body($body = $mail->body);
  26.  
  27. unshift @{$body},"---------- Begin Included Message ----------\n";
  28. push    @{$body},"----------- End Included Message -----------\n";
  29.  
  30. $file = "/tmp/reply.$$";
  31.  
  32. open(FILE,">$file") || die "Cannot open $file:$!\n";
  33.  
  34. $rply->print(\*FILE);
  35.  
  36. close(FILE);
  37.  
  38. $editor = $ENV{"EDITOR"} || "/usr/bin/nvi";
  39.  
  40. warn "$editor :$!\n" if (system("$editor $file"));
  41.  
  42. unlink($file,$file . '%');
  43.  
  44. exit 0;
  45.  
  46.